var express = require('express');
var router = express.Router();
var connection = require('../db/sql.js');
var user = require('../db/UserSql.js');
var jwt_decode = require('jwt-decode');

//验证码
let code = '';
//接入短信的sdk
var QcloudSms = require("qcloudsms_js");

/* GET home page. */
router.get('/', function (req, res, next) {
	res.render('index', {
		title: 'Express'
	});
});

// 2-1 用户登录
router.post('/api/login', function (req, res, next) {

	//前端给后端的数据
	let params = {
		userName: req.body.userName,
		userPwd: req.body.userPwd
	}
	//查询用户名或者手机号存在不存在
	connection.query(user.queryUserName(params), function (error, results, fields) {
		if (results.length > 0) {
			connection.query(user.queryUserPwd(params), function (err, result) {
				if (result.length > 0) {
					res.send({
						data: {
							success: true,
							msg: "登录成功",
							data: result[0]
						}
					})
				} else {
					res.send({
						data: {
							success: false,
							msg: "密码不正确"
						}
					})
				}
			})
		} else {
			res.send({
				data: {
					success: false,
					msg: "用户名或手机号不存在"
				}
			})
		}
	})
});

// 2-2 注册验证手机号是否存在
router.post('/api/registered', function (req, res, next) {

	//前端给后端的数据
	let params = {
		userName: req.body.phone
	};
	//查询手机号是否存在
	connection.query(user.queryUserName(params), function (error, results, fields) {
		if (results.length > 0) {
			res.send({
				data: {
					success: false,
					msg: "手机号已经存在"
				}
			})
		} else {
			res.send({
				data: {
					success: true
				}
			})
		}
	})

})

// 2-3 发送验证码
router.post('/api/code', function (req, res, next) {
	//前端给后端的数据
	let params = {
		userName: req.body.userName
	};
	// 短信应用 SDK AppID
	var appid = 1327503756; // SDK AppID 以1400开头
	// 短信应用 SDK AppKey
	var appkey = "AKIDgDrSqzub4RacTC0hCUhrsnpmcbQjzGMH";
	// 需要发送短信的手机号码
	var phoneNumbers = [params.userName];
	// 短信模板 ID，需要在短信控制台中申请
	var templateId = 298000; // NOTE: 这里的模板ID`7839`只是示例，真实的模板 ID 需要在短信控制台中申请
	// 签名
	var smsSign = "三人行慕课"; // NOTE: 签名参数使用的是`签名内容`，而不是`签名ID`。这里的签名"腾讯云"只是示例，真实的签名需要在短信控制台申请
	// 实例化 QcloudSms
	var qcloudsms = QcloudSms(appid, appkey);
	// 设置请求回调处理, 这里只是演示，用户需要自定义相应处理回调
	function callback(err, ress, resData) {
		if (err) {
			console.log("err: ", err);
		} else {
			code = ress.req.body.params[0];
			res.send({
				data: {
					success: true,
					code: code
				}
			})
		}
	}
	var ssender = qcloudsms.SmsSingleSender();
	var paramss = [Math.floor(Math.random() * (9999 - 1000)) + 1000]; //发送的验证码
	ssender.sendWithParam("86", phoneNumbers[0], templateId,
		paramss, smsSign, "", "", callback);

})

// 2-4 注册===>增加一条数据
router.post('/api/addUser', function (req, res, next) {
	//前端给后端的数据
	let params = {
		userName: req.body.userName,
		userCode: req.body.code
	};
	if (params.userCode == code) {
		// 新增
		connection.query(user.insertData(params), function (error, results, fields) {
			// 查询
			connection.query(user.queryUserName(params), function (err, result) {
				res.send({
					data: {
						success: true,
						msg: "注册成功",
						data: result[0]
					}
				})
			})
		})
	}

})

// 2-5 当前用户查询收货地址
router.post('/api/selectAddress', function (req, res, next) {

	let token = req.headers.token;
	let phone = jwt_decode(token);

	connection.query(`select * from user where phone = ${phone.name}`, function (error, results, fields) {
		let id = results[0].id;
		connection.query(`select * from address where userId = ${id}`, function (err, result, field) {
			res.send({
				data: result
			})
		})
	})
})

// 2-6 获取当前用户购物车列表
router.post('/api/selectCart', function (req, res, next) {
	connection.query(`select * from goods_cart`, function (error, results, fields) {
		if (error) throw error;
		res.send({
			code: "0",
			data: results
		})
	})
})

// 2-7 修改-购物车商品数量
router.post('/api/updateNumCart', function (req, res, next) {
	//商品id
	let goodsId = req.body.goodsId;
	//修改后的商品数量
	let num = req.body.num;
	connection.query(`select * from goods_cart where goods_id = ${goodsId}`, function (error, results, fields) {
		//修改前的数量
		let goods_num = results[0].num;
		//当前的id号
		let id = results[0].id;
		// console.log(results[0].id);
		connection.query(
			`update goods_cart set num = replace(num,${goods_num},${num})`,
			function (err, result) {
				res.json({
					data: {
						success: true
					}
				})
			})
	})
})

// 2-8 加入购物车
router.post('/api/addCart', function (req, res, next) {
	let goods_id = req.body.goods_id; //商品id
	let num = req.body.num; //用户输入的商品数量

	// 1. 查询加入的是哪个商品：
	connection.query(`select * from goods_search where id = ${goods_id}`, function (err, result) {
		let name = result[0].name;
		let imgUrl = result[0].imgUrl;
		let pprice = result[0].pprice;
		// 2. 查询购物车里是否存在该商品：
		connection.query(`select * from goods_cart where goods_id = ${goods_id}`, function (err, data) {
			// data : 存在的商品 /  []
			if (data.length > 0) {
				// 3-1. 存在-> 增加数量
				connection.query(
					`update goods_cart set num = replace(num,${data[0].num},${parseInt(num) + parseInt(data[0].num)}) where id = ${data[0].id}`,
					function (e, r) {
						res.json({
							data: {
								success: "加入成功"
							}
						})
					})
			} else {
				// 3-2. 没有-> 增加商品
				connection.query(
					'insert into goods_cart (uId,goods_id,name,imgUrl,pprice,num) values ("1","' +
					goods_id + '","' + name + '","' + imgUrl + '","' + pprice + '","' +
					num + '")',
					function (e, r) {
						res.json({
							data: {
								success: '加入成功'
							}
						})
					})
			}

		})
	})
})




// 2-9 删除购物车商品数据
router.post('/api/deleteCart', function (req, res, next) {
	let goodsId = req.body.goodsId;
	// console.log(goodsId);
	for (var i = 0; i < goodsId.length; i++) {
		connection.query(`delete from goods_cart where id=${goodsId[i]}`, function (e, r) {
			res.json({
				data: {
					success: true
				}
			})
		})
	}
})

// 2-10 生成订单
router.post('/api/addOrder', function (req, res, next) {
	let goodsArr = req.body.arr; //前端给后端传递的数据
	// console.log(goodsArr);

	//生成订单号
	function setTimeDateFmt(s) {
		return s < 10 ? '0' + s : s;
	}
	function orderNumber() {
		const now = new Date();
		let fullYear = now.getFullYear();
		let month = setTimeDateFmt(now.getMonth() + 1);
		let day = setTimeDateFmt(now.getDate());
		let hour = setTimeDateFmt(now.getHours());
		let minutes = setTimeDateFmt(now.getMinutes());
		let seconds = setTimeDateFmt(now.getSeconds());
		let orderCode = fullYear + month + day + hour + minutes + seconds + (Math.round(Math.random() * 1000000));
		return orderCode;
	}

	let goodsName = ''; //商品名称

	let goodsPrice = 0; //订单总价

	let goodsNum = 0; //订单商品总数量
	let orderId = orderNumber();
	// let orderId = new Date().getTime(); //订单号 获取毫秒级时间戳  
	console.log(orderId);

	goodsArr.forEach(v => {
		goodsName.push(v.name);
		goodsNum += parseInt(v.num);
		goodsPrice += v.num * v.pprice;
	})
	// console.log(orderId);
	// console.log(goodsName);
	// console.log(goodsPrice);
	// 1. 新增订单
	// `insert into store_order (uId,order_id,goods_name,goods_price,goods_num,order_status) values ("1",'${orderId}','${goodsName}','${goodsPrice}','${goodsNum}','1')`
	connection.query(
		`insert into store_order (uId,order_id,goods_name,goods_price,goods_num,order_status) values ("1","${orderId}","${goodsName}","${goodsPrice}","${goodsNum}",'1')`,
		function () {
			console.log(1);
			connection.query(`select * from store_order where order_id = ${orderId}`,
				function (err, result) {
					res.send({
						data: {
							code: 200,
							success: true,
							data: result
						}
					})
				})
		})
})




// 测试token
router.post('/api/token', function (req, res, next) {
	res.render({
		data: {
			a: 1
		}
	});
});




// 1-通过数据库-搜索框
router.get('/api/goods/search', function (req, res, next) {
	// desc 降序 asc升序
	//获取对象的key
	let [goodsName, orderName] = Object.keys(req.query)
	//name参数的值
	let name = req.query.name;
	//orderName的key的值
	let order = req.query[orderName];

	connection.query("select * from goods_search where name like '%" + name + "%' order by " + orderName + " " +
		order + "",
		function (error, results, fields) {
			if (error) throw error
			// console.log(req.query);//传参
			res.send({
				code: "0",
				data: results
			})


		})
});

// 2-分类数据
router.get('/api/goods/list', function (req, res, next) {
	res.json({
		code: 0,
		data: [{
			id: 1,
			name: "家居家纺",
			data: [{
				name: "休闲套装",
				list: [
					{
						id: 7,
						name: "森女部落 原创UPF100+时尚防晒元气吊带甜美户外防晒衣高腰百搭牛仔短裤休闲套装",
						imgUrl: "../../static/list/girl1.jpg",
						pprice: "297",
						oprice: "732",
						discount: '7'
					},
					{
						id: 8,
						name: "UTHA 透气爽滑垂坠感上衣条纹百搭吊带中腰合身下衣休闲套装 女款 杏色",
						imgUrl: "../../static/list/girl2.jpg",
						pprice: "181",
						oprice: "323",
						discount: '5'
					},
					{
						id: 9,
						name: "森女部落 x Disney 联名款 疯狂动物城 原创立体章仔DIY闺蜜装T恤可爱背带裤休闲套装",
						imgUrl: "../../static/list/girl3.jpg",
						pprice: "227",
						oprice: "689",
						discount: '4'
					},
					{
						id: 10,
						name: "森女部落 原创手绘图案漫画感T恤少女感花边蛋糕裙甜美套装夏季 女款 白色",
						imgUrl: "../../static/list/girl4.jpg",
						pprice: "235",
						oprice: "321",
						discount: '8'
					},
					{
						id: 11,
						name: "森女部落 原创UPF100+时尚防晒元气吊带甜美户外防晒衣高腰百搭牛仔短裤休闲套装",
						imgUrl: "../../static/list/girl1.jpg",
						pprice: "200",
						oprice: "400",
						discount: '5'
					},
					{
						id: 12,
						name: "UTHA 透气爽滑垂坠感上衣条纹百搭吊带中腰合身下衣休闲套装 女款 杏色",
						imgUrl: "../../static/list/girl2.jpg",
						pprice: "257",
						oprice: "290",
						discount: '8'
					}

				]
			},
			{
				name: "短袖连衣裙",
				list: [{
					id: 13,
					name: "森女部落 x Disney 联名款 疯狂动物城朱迪 原创假两件连衣裙短袖蓬蓬花苞裙夏季",
					imgUrl: "../../static/list/girls1.jpg",
					pprice: "297",
					oprice: "732",
					discount: '7'
				},
				{
					id: 14,
					name: "RTNH 纯色娃娃领泡泡短袖连衣裙 女款 杏色",
					imgUrl: "../../static/list/girls2.jpg",
					pprice: "297",
					oprice: "732",
					discount: '7'
				},
				{
					id: 15,
					name: "礼袋装XUANSHU悬殊 仙女初恋裙法式复古名媛风不规则裙边设计收腰方领提花蕾丝边绑带中长款甜美淑女气质短袖连衣裙 女款 杏色",
					imgUrl: "../../static/list/girls3.jpg",
					pprice: "297",
					oprice: "732",
					discount: '7'
				},
				{
					id: 16,
					name: "东鲸岁时记 学院风miu系纯色翻领套头中长款裙子A字宽松显瘦遮肚子法式气质公主裙泡泡短袖连衣裙 春夏季 女款 礼盒装 白日梦想家",
					imgUrl: "../../static/list/girls4.jpg",
					pprice: "297",
					oprice: "732",
					discount: '7'
				},
				{
					id: 17,
					name: "礼袋装XUANSHU悬殊 仙女初恋裙法式复古名媛风不规则裙边设计收腰方领提花蕾丝边绑带中长款甜美淑女气质短袖连衣裙 女款 杏色",
					imgUrl: "../../static/list/girls3.jpg",
					pprice: "297",
					oprice: "732",
					discount: '7'
				},
				{
					id: 10,
					name: "东鲸岁时记 学院风miu系纯色翻领套头中长款裙子A字宽松显瘦遮肚子法式气质公主裙泡泡短袖连衣裙 春夏季 女款 礼盒装 白日梦想家",
					imgUrl: "../../static/list/girls4.jpg",
					pprice: "297",
					oprice: "732",
					discount: '7'
				},
				]
			}
			]
		},
		{
			id: 2,
			name: "鞋类",
			data: [{
				name: "儿童鞋",
				list: [{
					id: 18,
					name: "儿童 adidas originals FORUM 运动 防水 低帮 儿童跑步鞋 白粉色",
					imgUrl: "../../static/list/xie1.jpg"
				},
				{
					id: 19,
					name: "儿童 KAPPA KIDS 轻便 软弹 舒适 防踢耐磨 低帮 儿童跑步鞋 米蓝",
					imgUrl: "../../static/list/xie2.jpg"
				}
				]
			},
			{
				name: "上衣",
				list: [{
					id: 1,
					name: "T恤",
					imgUrl: "../../static/list/girl2.jpg"
				},
				{
					id: 2,
					name: "衬衫",
					imgUrl: "../../static/list/girl4.jpg"
				}
				]
			}
			]
		},
		{
			id: 3,
			name: "数码",
		},
		{
			id: 4,
			name: "配饰",
		},
		{
			id: 5,
			name: "美妆",
		},
		{
			id: 6,
			name: "运动",
		},
		{
			id: 7,
			name: "男装",
		},
		{
			id: 8,
			name: "包袋",
		},
		{
			id: 9,
			name: "配饰",
		},
		{
			id: 10,
			name: "美妆",
		},
		{
			id: 11,
			name: "运动",
		},
		{
			id: 12,
			name: "男装",
		},
		{
			id: 13,
			name: "包袋",
		},

		]
	})
});

// 3-通过id查询商品详情
router.get('/api/goods/id', function (req, res, next) {
	let id = req.query.id;
	connection.query("select * from goods_search where id=" + id + "", function (error, results, fields) {
		if (error) throw error;
		res.send({
			code: "0",
			data: results
		})
	});
});




// 1. 首页(推荐)的数据
router.get("/api/index_list/data", function (req, res, next) {
	res.send({
		"code": 0,
		"data": {
			topBar: [{
				id: 1,
				name: '推荐'
			},
			{
				id: 2,
				name: '运动户外'
			},
			{
				id: 3,
				name: '服饰内衣'
			},
			{
				id: 4,
				name: '鞋靴箱包'
			},
			{
				id: 5,
				name: '美妆个护'
			},
			{
				id: 6,
				name: '家居数码'
			},
			{
				id: 7,
				name: '食品母婴'
			}
			],
			data: [{
				type: "swiperList",
				data: [{
					imgUrl: '../../static/img/swiper1.jpg'
				},
				{
					imgUrl: '../../static/img/swiper2.jpg'
				},
				{
					imgUrl: '../../static/img/swiper3.jpg'
				}
				]
			},
			{
				type: "recommendList",
				data: [{
					bigUrl: "../../static/img/Children.jpg",
					data: [{
						imgUrl: "../../static/img/Children1.jpg"
					},
					{
						imgUrl: "../../static/img/Children2.jpg"
					},
					{
						imgUrl: "../../static/img/Children3.jpg"
					}
					]
				},
				{
					bigUrl: "../../static/img/Furnishing.jpg",
					data: [{
						imgUrl: "../../static/img/Furnishing1.jpg"
					},
					{
						imgUrl: "../../static/img/Furnishing2.jpg"
					},
					{
						imgUrl: "../../static/img/Furnishing3.jpg"
					}
					]
				}
				]
			},
			{
				type: "commodityList",
				data: [{
					id: 1,
					imgUrl: "../../static/img/commodity1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/commodity2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/commodity3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/commodity4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				}
				]
			}
			]
		}
	})
});

// 2. 首次第一次触底的数据
router.get('/api/index_list/1/data/2', function (req, res, next) {
	res.json({
		code: "0",
		data: [{
			type: "commodityList",
			data: [{
				id: 1,
				imgUrl: "../../static/img/commodity1.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 2,
				imgUrl: "../../static/img/commodity2.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 3,
				imgUrl: "../../static/img/commodity3.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 4,
				imgUrl: "../../static/img/commodity4.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			}
			]
		}]
	})
})

// 3. 服饰内衣第一次加载的数据
router.get('/api/index_list/3/data/1', function (req, res, next) {
	res.json({
		code: "0",
		data: [{
			type: "bannerList",
			imgUrl: "../../static/img/banner1.jpg"
		},
		{
			type: "iconsList",
			data: [{
				imgUrl: "../../static/img/icons1.png",
				name: "服饰内衣"
			},
			{
				imgUrl: "../../static/img/icons2.png",
				name: "服饰内衣"
			},
			{
				imgUrl: "../../static/img/icons3.png",
				name: "服饰内衣"
			},
			{
				imgUrl: "../../static/img/icons4.png",
				name: "服饰内衣"
			},
			{
				imgUrl: "../../static/img/icons5.png",
				name: "服饰内衣"
			},
			{
				imgUrl: "../../static/img/icons6.png",
				name: "服饰内衣"
			},
			{
				imgUrl: "../../static/img/icons7.png",
				name: "服饰内衣"
			},
			{
				imgUrl: "../../static/img/icons8.png",
				name: "服饰内衣"
			}
			]
		},
		{
			type: "hotList",
			data: [{
				id: 1,
				imgUrl: "../../static/img/hot1.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 2,
				imgUrl: "../../static/img/hot2.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 3,
				imgUrl: "../../static/img/hot3.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			}
			]
		},
		{
			type: "shopList",
			data: [{
				bigUrl: "../../static/img/shop.jpg",
				data: [{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				}
				]
			},
			{
				bigUrl: "../../static/img/shop.jpg",
				data: [{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				}
				]
			}
			]
		},
		{
			type: "commodityList",
			data: [{
				id: 1,
				imgUrl: "../../static/img/commodity1.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 2,
				imgUrl: "../../static/img/commodity2.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 3,
				imgUrl: "../../static/img/commodity3.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 4,
				imgUrl: "../../static/img/commodity4.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			}
			]
		}
		]
	})
});

// 4. 运动户外的数据
router.get('/api/index_list/2/data/1', function (req, res, next) {
	res.json({
		code: "0",
		data: [{
			type: "bannerList",
			imgUrl: "../../static/img/banner1.jpg"
		},
		{
			type: "iconsList",
			data: [{
				imgUrl: "../../static/img/icons1.png",
				name: "运动户外"
			},
			{
				imgUrl: "../../static/img/icons2.png",
				name: "运动户外"
			},
			{
				imgUrl: "../../static/img/icons3.png",
				name: "运动户外"
			},
			{
				imgUrl: "../../static/img/icons4.png",
				name: "运动户外"
			},
			{
				imgUrl: "../../static/img/icons5.png",
				name: "运动户外"
			},
			{
				imgUrl: "../../static/img/icons6.png",
				name: "运动户外"
			},
			{
				imgUrl: "../../static/img/icons7.png",
				name: "运动户外"
			},
			{
				imgUrl: "../../static/img/icons8.png",
				name: "运动户外"
			}
			]
		},
		{
			type: "hotList",
			data: [{
				id: 1,
				imgUrl: "../../static/img/hot1.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 2,
				imgUrl: "../../static/img/hot2.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 3,
				imgUrl: "../../static/img/hot3.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			}
			]
		},
		{
			type: "shopList",
			data: [{
				bigUrl: "../../static/img/shop.jpg",
				data: [{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				}
				]
			},
			{
				bigUrl: "../../static/img/shop.jpg",
				data: [{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 1,
					imgUrl: "../../static/img/shop1.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 2,
					imgUrl: "../../static/img/shop2.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 3,
					imgUrl: "../../static/img/shop3.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				},
				{
					id: 4,
					imgUrl: "../../static/img/shop4.jpg",
					name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
					pprice: "299",
					oprice: "659",
					discount: "5.2"
				}
				]
			}
			]
		},
		{
			type: "commodityList",
			data: [{
				id: 1,
				imgUrl: "../../static/img/commodity1.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 2,
				imgUrl: "../../static/img/commodity2.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 3,
				imgUrl: "../../static/img/commodity3.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 4,
				imgUrl: "../../static/img/commodity4.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			}
			]
		}
		]
	})
});

//运动户外第一次触底的数据
router.get('/api/index_list/2/data/2', function (req, res, next) {
	res.json({
		code: "0",
		data: [{
			type: "commodityList",
			data: [{
				id: 1,
				imgUrl: "../../static/img/commodity1.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 2,
				imgUrl: "../../static/img/commodity2.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 3,
				imgUrl: "../../static/img/commodity3.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 4,
				imgUrl: "../../static/img/commodity4.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			}
			]
		}]
	})
})

// 5. 运动户外第二次触底的数据
router.get('/api/index_list/2/data/3', function (req, res, next) {
	res.json({
		code: "0",
		data: [{
			type: "commodityList",
			data: [{
				id: 1,
				imgUrl: "../../static/img/commodity1.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 2,
				imgUrl: "../../static/img/commodity2.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 3,
				imgUrl: "../../static/img/commodity3.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			},
			{
				id: 4,
				imgUrl: "../../static/img/commodity4.jpg",
				name: "大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008大姨绒毛大款2020年必须买,不买你就不行了,爆款疯狂GG008",
				pprice: "299",
				oprice: "659",
				discount: "5.2"
			}
			]
		}]
	})
})


module.exports = router;